<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<jsp:include page="../links.jsp"></jsp:include>
<script type="text/javascript">
	$(function() {
		var customerAdd_form;
		var customerDel_form;
		customerAdd_form = $('#customerAdd_form').form({
			url : getRootPath() + '/customerAction/c_add.do',
			success : function(r) {
				r = $.parseJSON(r);//将标准json转成obj
				if (r && r.success) {
					$.messager.show({
						title : '提示',
						msg : '添加成功',
						showType : 'show'
					});
				} else {
					$.messager.alert('提示', '用户已存在'); 
				}
			}
		});
		customer_add_fun = function() {
			if ($('#cname1').val() == null || $('#cname1').val() == "") {
				$.messager.alert('提示', '请输入客户名');
				return false;
			}
			if ($('#caddress1').val() == null || $('#caddress1').val() == "") {
				$.messager.alert('提示', '请输入联系地址');
				return false;
			}
			if ($('#ctel2').val() == null || $('#ctel2').val() == "") {
				$.messager.alert('提示', '请输入联系电话');
				return false;
			}
			if ($('#ccompany1').val() == null || $('#ccompany1').val() == "") {
				$.messager.alert('提示', '请输入公司名');
				return false;
			}
			if ($('#cposition1').val() == null || $('#cposition1').val() == "") {
				$.messager.alert('提示', '请输入职务');
				return false;
			} else {
				$('#customerAdd_form').submit();
			}
			return true;
		}
		customerDel_form = $('#customerDel_form').form({
			url : getRootPath() + '/customerAction/c_delete.do',
			success : function(r) {
				r = $.parseJSON(r);//将标准json转成obj
				if (r && r.success) {
					$.messager.show({
						title : '提示',
						msg : '删除成功',
						showType : 'show'
					});
				} else {
					$.messager.alert('提示', '用户不存在');
				}
			}
		});
		customer_del_fun = function() {
			if ($('#cid3').val() == null || $('#cid3').val() == "") {
				$.messager.alert('提示', '请输入编号');
				return false;
			}else {
				$('#customerDel_form').submit();
			}
			return true;
		}
	})
</script>
<div id="customerAdd" style="position: absolute; left: 25%; top: 5%;">
	<form id="customerAdd_form" method="post">
		<table cellpadding="5">
			<tr>
				<th>客户姓名</th>
				<td><input id="cname1" class="easyui-validatebox" type="text" name="cname" data-options="novalidate:true "></input></td>
			</tr>
			<tr>
				<th>性别</th>
				<td><select class="easyui-combobox" name="cgender" style="width: 155%;" panelHeight="41px">
						<option value="男">男</option>
						<option value="女">女</option>
				</select></td>
			</tr>
			<tr>
				<th>联系地址</th>
				<td><input id="caddress1" class="easyui-validatebox" type="text" name="caddress"
					data-options="novalidate:true "></input></td>
			</tr>
			<tr>
				<th>出生年月</th>
				<td><input name="cbirth" class="easyui-datebox" editable="false"
					data-options="required:true,missingMessage:'请输入日期'" /></td>
			</tr>
			<tr>
				<th>联系电话</th>
				<td><input id="ctel2" class="easyui-validatebox" type="text" name="ctel" data-options="novalidate:true "></input></td>
			</tr>
			<tr>
				<th>公司名称</th>
				<td><input id="ccompany1" class="easyui-validatebox" type="text" name="ccompany"
					data-options="novalidate:true "></input></td>
			</tr>
			<tr>
				<th>职务</th>
				<td><input id="cposition1" class="easyui-validatebox" type="text" name="cposition"
					data-options="novalidate:true "></input></td>
			</tr>
			<tr>
				<td colspan="2"><span><a href="javascript:;" class="easyui-linkbutton" style="width: 288px;"
						onclick="customer_add_fun()"><font color="green">添加 客户</font></a></span></td>
			</tr>
		</table>
	</form>
	<form id="customerDel_form" action="">
		<table>
			<tr>
				<th>输入要删除客户的编号(*)</th>
			</tr>
			<tr>
				<td><input id="cid3"  style="width: 288px;" class="easyui-validatebox" type="text" name="cid" data-options="novalidate:true"></input></td>
			</tr>
			<tr>
				<td colspan="2"><span><a href="javascript:;" class="easyui-linkbutton" style="width: 288px;"
						onclick="customer_del_fun()"><font color="red">删除 客户</font></a></span></td>
			</tr>
		</table>
	</form>
</div>